home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 12 / BBS in a box XII-2.iso / Files II / Prog / T / ToolsPlus 2.1.sit / Tools Plus 2.1 ƒ / Tools Plus 2.1 (C & Pascal) / User Manual / 19-Completing Your Application < prev    next >
Encoding:
Text File  |  1993-10-24  |  26.3 KB  |  397 lines  |  [TEXT/ttxt]

  1. 19  Completing Your Application
  2. ```````````````````````````````
  3.  
  4. This section details the final steps that you must take to produce a stand-alone, double-clickable application.  The requirements for an application using Tools Plus libraries are nearly identical to those of ordinary Macintosh applications, except that the SIZE resource has some very specific needs.  It is assumed that by the time you address these concerns, that you have already written and debugged an application within your development environment and that you are ready to make it into a stand-alone application.
  5.  
  6. All the work encompassed in this section requires that you use a resource editor such as Apple’s ResEdit to create and/or modify resources.  The THINK C and THINK Pascal development environment allows you to use a resource file in your project.  That resource file is automatically merged into your compiled code when you build your project.  Therefore we recommend you create and save these resources in a separate resource file and allow your development environment to merge them with your application.
  7.  
  8. Completing your application involves making some decisions, then creating the appropriate resources.  The table below summarizes the various tasks and their significance to your final application.
  9.  
  10.  
  11.  
  12. Task (section in this chapter) | Significance to your application
  13. -------------------------------+----------------------------------------
  14. Application Icons              | Defines the icons that are displayed by
  15. File Types, Creators, and the  | the Finder for your application and the
  16.    Application Signature       | files it creates.
  17. Bundle                         | 
  18. -------------------------------+----------------------------------------
  19. Version                        | For displaying a version number in your
  20.                                | application’s “Get Info” box.  An
  21.                                | application description can also be
  22.                                | displayed. (Optional)
  23. -------------------------------+----------------------------------------
  24. mstr resource                  | Remapping of the File menu’s “Quit”
  25.                                | item and the File menu’s “Open…” item
  26.                                | to another menu and/or menu item.
  27.                                |    The “Quit”  command is automatically
  28.                                | invoked when your application is
  29.                                | running and the user selects the
  30.                                | Special menu’s Restart or Shut Down
  31.                                | commands.
  32.                                |    The “Open…” command is automatically
  33.                                | invoked when your application is
  34.                                | running and the user double-clicks
  35.                                | (opens) a document created by your
  36.                                | application.
  37.                                |    If your application does not have
  38.                                | the “Open…” or “Quit” items in a “File”
  39.                                | menu, you need to add mstr resources.
  40.                                | (Optional)
  41. -------------------------------+----------------------------------------
  42. SIZE resource                  | Defines your application’s behavior and
  43.                                | memory requirements in a multi-
  44.                                | tasking environment.  Needed for
  45.                                | MultiFinder and System 7 (and higher).
  46.  
  47.  
  48.  
  49.  
  50.  
  51. Application’s Icons
  52. ```````````````````
  53. The Macintosh’s Finder is the part that is responsible for displaying an application and its related files as icons.  In order for the Finder to do this, it needs to know what each icon looks like.  Without this information, your application will have the “generic application” icon (diamond with a hand holding a pen) and its related files will have the “generic document” icon (blank page with corner folded down).
  54.  
  55. At the very least, you will need  to create a large (32x32 bit) black and white icon (ICN#) for your application, and one for each type of document it creates.  You should also consider creating equivalent small (16x16 bit) black and white icons (ics#), because the Finder displays these miniatures when a disk’s or folder’s view is set to “small icon,” or when System 7 displays lists with icons.
  56.  
  57. System 7 can display your application’s icons in color, so you can optionally include color icons as equivalents for the black and white ones.  The icl8 and icl4 icon types are large icons using 8 bits (256 colors) and 4 bits (16 colors) respectively.  Small color icons can also be created as ics8 and ics4 type icons.  Later, the “bundle” describes how to integrate the icon resources into your finished application.
  58.  
  59.  
  60.  
  61.  
  62.  
  63. Icon Family
  64. ```````````
  65. When a specific icon ID number is shared by two or more icon types, those related icons are called an “icon family.”  The icon family with an ID of 128 is usually the icon that depicts your application.  Your application’s document icons would likely be numbered 129 and up.  When you create icons, remember to use ID numbers 128 or higher.  The rest are reserved numbers.
  66.  
  67. Note: When creating icl8 and ics8 icons with ResEdit, you have a choice
  68.       of two pallets: “Apple icon colors” or “Standard 256 colors.”  Use
  69.       the Apple icon colors, since they will guarantee that your icon
  70.       can be selected (darkened) properly.
  71.  
  72.  
  73.  
  74.  
  75.  
  76. File Types, Creators, and the Application Signature
  77. ```````````````````````````````````````````````````
  78. On the Macintosh, all files (including application, desk accessories, documents, etc.) have a file type and a creator code.  Both of these items are always four characters long, allowing any visible or invisible characters and spaces.  The file type tells the Macintosh what the file contains.  Your application will always have a file type of ‘APPL.’  You can define your own file types for the documents created by your application if they don’t fit into any of the existing general types as follows:
  79.  
  80.     APPL    Launchable application
  81.     DFIL    File for sorting DAs
  82.     DRVR    Driver
  83.     FFIL    File for sorting fonts
  84.     INIT    System extension
  85.     PICT    QuickDraw picture
  86.     PRER    Printer driver
  87.     RDEV    Chooser extension
  88.     TEXT    Stream of ASCII characters
  89.     adev    Network extension
  90.     appe    Background-only application
  91.     cdev    Control panel
  92.     edtp    Edition for sharing graphics
  93.     edts    Edition for sharing sound
  94.     edtt    Edition for sharing text
  95.     ffil    Font
  96.     ifil    Script system resources
  97.     kfil    Keyboard layout
  98.     pref    Preferences file
  99.     qery    Query document (databases)
  100.     scri    System extension for scripting
  101.     sfil    Sound
  102.     tfil    TrueType font
  103.     ttro    TeachText read-only file
  104.     zsys    A system file
  105.  
  106. Later, the “bundle” describes how to integrate file type(s) into your finished application.
  107.  
  108.  
  109.  
  110.  
  111.  
  112. Signature (the Creator code)
  113. ````````````````````````````
  114. Each application must have a unique, four character signature.  A signature is often called a creator code because it answers the question “who created me” for every document on a Macintosh (an application is considered to be its own creator).  Your application’s signature will be used as the creator code for all the documents it creates.
  115.  
  116. The Finder makes an association between each application and its related documents by using the application’s signature.  When a document is opened by the Finder, it knows which application created the file and automatically launches that application.
  117.  
  118. Notice that some file types can be opened by several applications.  If you double-click a ‘TEXT’ file, it will be opened by the application that launched it (because the Finder recognizes the creator for the file is identical to the parent application’s signature).  However, just about any word processor can open a ‘TEXT’.
  119.  
  120. In THINK Pascal, you set your application’s type and creator by using the Project menu’s “Set project Type” command.  Later, the “bundle” describes how to integrate the signature into your finished application.
  121.  
  122.  
  123. Note: Apple reserves the use of all file types and signatures (creator
  124.       codes) whose names contain only lowercase letters, and those that
  125.       contain only non-alphabetic characters.  Your file types and
  126.       signatures must contain at least one uppercase letter.  Since the
  127.       system software never displays the file type or signature to
  128.       users, these codes don’t have to be meaningful to anyone but you.
  129.          All file types and signatures must be registered with Apple to
  130.       guarantee uniqueness and prevent conflicts between application.
  131.  
  132. Warning: When deciding upon a signature for your application, be careful
  133.          to avoid signatures that are identical to any existing resource
  134.          type, such as ‘ICON’ or ‘STR ’.  An owner resource must be
  135.          created with a type that matches your application’s signature,
  136.          and if it coincides with existing resources types, conflicts
  137.          may arise.  For a comprehensive list of resource codes, please
  138.          refer to the ResEdit Reference manual, or contact Apple.
  139.  
  140.  
  141.  
  142.  
  143.  
  144. Bundle
  145. ``````
  146. The BNDL resource, which is simply called the “bundle,” is used to “bundle up” several related resources that are needed to define the association between your application, its documents, and the icons displayed by the Finder.  If you use ResEdit to create the BNDL resource, you will be presented with a template that that lets you create and maintain the BNDL resource
  147.  
  148. Enter the four character signature your have selected for your application.
  149.  
  150. Next, use the Resource menu’s “Create New File Type” command to create a new line.  Enter the file type.  Note that the first line should have a type of ‘APPL’ (application).  Double-click its “Finder Icons” section and you will be presented with a list of icons that you created earlier in the “Application Icons” section of this chapter.  Select the icon you want to use to represent the specified file type.  Repeat this for each file type that is supported by your application.
  151.  
  152. The last thing you must do to complete the bundle is to set the “bundle bit.”  The bundle bit tells the Finder that your application has a bundle present.  In THINK Pascal, you set the bundle bit by using the Project menu’s “Set project Type” command, then building your application.
  153.  
  154. When creating the BNDL resource, ResEdit automatically creates several other supporting resources.  One FREF resource (Finder REFerence) is created for each file type.  An “Owner Resource” is also created (ID=0).  Its resource type matches your application’s signature.  The owner resource is essentially a string resource that lets you enter a comment that is displayed as version information in the Finder’s “Get Info” box (providing you don’t create ‘vers’ resources).
  155.  
  156.  
  157. Note: If you change your application’s icons, you will have to rebuild
  158.       the desk top file to force the Finder to use your new icons.  To
  159.       rebuild the desk top, restart your Macintosh while holding the
  160.       option and command keys down, and continue to hold them until you
  161.       see a dialog that asks you if you want to rebuild your desk top.
  162.       Click the OK button to start rebuilding.
  163.          A similar problem occurs when an application is copied to a
  164.       disk using an installer or decompression program.  These kinds of
  165.       programs typically don’t have the intelligence to update the desk
  166.       top file like the Finder does.
  167.  
  168.  
  169.  
  170.  
  171.  
  172. Version
  173. ```````
  174. Your application can display some descriptive information in the Finder’s “Get Info” box by having ‘vers’ resources.  The two vers resources you can include in your applications are:
  175.  
  176.    ID=1  Application version number (i.e. 1.2, ©1993 - Water’s Edge
  177.          Software)
  178.  
  179.    ID=2  Application info displayed beneath the file name
  180.  
  181. By using vers resources, any file can bear version information, including documents created by your application.
  182.  
  183.  
  184.  
  185.  
  186.  
  187. mstr Resources
  188. ``````````````
  189. Both MultiFinder (running under System 5 or 6) and System 7 (and higher) can automatically interact with your application through its menus.  If your application is running while the user double-clicks (or select-opens) one of your application’s documents from the Finder, the affected document is automatically opened by your application.  Also, if the user selects the Special menu’s Restart or Shut Down command while your application is running, it will be instructed to quit.
  190.  
  191. In both these cases, the system simulates the selection of a menu item.  Typically applications have a File menu with an item named “Open…” (including the ellipsis, the Option-; character), and the last item named “Quit”.  In the case of opening a document, PollSystem returns a doMenu event to your application indicating that the File menu’s “Open…” command was selected, in which case your application would do whatever is appropriate, like display an SFGetFile dialog to let the user choose which file to open.  The system fools your application into thinking that the double-clicked file was selected from an SFGetFile dialog (which is not actually displayed).  When the user selects Restart or Shut Down, PollSystem returns a doMenu event to your application indicating that the File menu’s “Quit” command was selected, in which case your application would do whatever is appropriate, such as asking if open documents should be saved before quitting.
  192.  
  193. If your application does not [1] open files by using the File menu’s “Open…” command, or [2] quit by using the File menu’s “Quit” command, these functions can be remapped to other menu items by including ‘mstr’ resources in your application.  Each mstr resource is a Pascal string (byte-0 is the length byte) which tells the Macintosh which menu and menu item to use in place of the standards:
  194.  
  195.    mstr ID=100   Name of the menu containing the equivalent of the
  196.                  ‘Quit’ command
  197.  
  198.    mstr ID=101   Name of the menu item that is the equivalent of the
  199.                  ‘Quit’ command
  200.  
  201.    mstr ID=102   Name of the menu containing the equivalent of the
  202.                  ‘Open…’ command
  203.  
  204.    mstr ID=103   Name of the menu item that is the equivalent of the
  205.                  ‘Open…’ command
  206.  
  207.  
  208.  
  209.  
  210.  
  211. SIZE Resource
  212. `````````````
  213. If your application is going to run under MultiFinder or System 7 (or higher) it needs a SIZE resource.  ResEdit has a resource template for the SIZE resource, which lets you set various values in the resource that specify how your application behaves in a multi-tasking environment.
  214.  
  215. You will create a single resource with an ID of -1, but be aware that the Macintosh may clone (make a duplicate with a possible minor variation) your SIZE resource in your stand-alone application under certain conditions.  This is described later.
  216.  
  217. The SIZE resource is comprised of sixteen bits that can be set to a value of 0 or 1, and two long integers.  Tools Plus requires that some of these items be set to a specific value while others depend upon how you want your application to behave.  The table below details the SIZE resource.
  218.  
  219.  
  220.         Compulsory Setting \   / Recommended Setting
  221.                             \ /
  222. SIZE Template’s Field Name | | | Comments
  223. ---------------------------+-+-+----------------------------------------
  224. Save screen (obsolete)     |0|0| (obsolete)
  225. ---------------------------+-+-+----------------------------------------
  226. Accept suspend events      | |1| 0 = doSuspend and doResume events are
  227.                            | | |     not reported to your application.
  228.                            | | | 1 = Your application receives a
  229.                            | | |     doSuspend event prior to being
  230.                            | | |     suspended, and a doResume event
  231.                            | | |     immediately after being activated.
  232. ---------------------------+-+-+----------------------------------------
  233.                            |0|0| (obsolete)
  234. ---------------------------+-+-+----------------------------------------
  235. Can background             | |0| 0 = When your application is suspended,
  236.                            | | |     it receives no processing time
  237.                            | | | 1 = When your application is suspended,
  238.                            | | |     it receives processing time in the
  239.                            | | |     way of doNothing events.
  240.                            | | | If “Accept suspend events” is set to 0,
  241.                            | | | this item should be set to 1.
  242. ---------------------------+-+-+----------------------------------------
  243. Does activate on FG switch | |1| 0 = The Macintosh’s operating system
  244.                            | | |     takes care of activating and
  245.                            | | |     deactivating a window when the
  246.                            | | |     application is suspended or
  247.                            | | |     resumed.
  248.                            | | | 1 = Your application takes care of
  249.                            | | |     activating or deactivating its
  250.                            | | |     windows in response to a doSuspend
  251.                            | | |     or doResume event (automatic in
  252.                            | | |     Tools Plus).
  253.                            | | | This item should have the same setting
  254.                            | | | as “Accept suspend events.”
  255. ---------------------------+-+-+----------------------------------------
  256. Only background            | |0| 0 = Your application is a regular
  257.                            | | |     application.
  258.                            | | | 1 = Your application runs only in the
  259.                            | | |     background.  Usually, this is
  260.                            | | |     because it doesn’t have a user-
  261.                            | | |     interface and cannot run in the
  262.                            | | |     foreground.
  263.                            | | | This item can be set to 1 only if “Can
  264.                            | | | background” is set to 1.
  265. ---------------------------+-+-+----------------------------------------
  266. Get front clicks           | |0| 0 = When the user clicks on one of your
  267.                            | | |     application’s windows to make it
  268.                            | | |     the active application, your
  269.                            | | |     application is activated.
  270.                            | | | 1 = When the user clicks on one of your
  271.                            | | |     application’s windows to make it
  272.                            | | |     the active application, your
  273.                            | | |     application is activated and a
  274.                            | | |     doClick event is reported in the
  275.                            | | |     window that was clicked (i.e. the
  276.                            | | |     click is reported to your
  277.                            | | |     application)
  278. ---------------------------+-+-+----------------------------------------
  279. Accept app died events     | |0| 0 = ApplicationDied events are not
  280. (debuggers)                | | |     generated
  281.                            | | | 1 = Your application is notified (via
  282.                            | | |     an ApplicationDied event) when an
  283.                            | | |     application or process launched by
  284.                            | | |     your application has terminated or
  285.                            | | |     has crashed.  Read about System 7’s
  286.                            | | |     Process Manager for more details.
  287. ---------------------------+-+-+----------------------------------------
  288. 32 bit compatible          | |0| 0 = Your application is not 32-bit
  289.                            | | |     compatible
  290.                            | | | 1 = Your application can be run with
  291.                            | | |     the 32-bit Memory Manager.
  292.                            | | | Don’t set this flag to 1 unless you
  293.                            | | | have thoroughly tested your application
  294.                            | | | on a 32-bit system, such as on a
  295.                            | | | Macintosh IIci running System 7.0 (or
  296.                            | | | higher) in 32-bit mode.
  297. ---------------------------+-+-+----------------------------------------
  298. High level event aware     | |0| 0 = No high-level events are received
  299.                            | | |     or sent by your application
  300.                            | | | 1 = Your application can receive and
  301.                            | | |     send high-level events (System 7
  302.                            | | |     only, or higher)
  303. ---------------------------+-+-+----------------------------------------
  304. Local and remote high      | |0| 0 = Your application cannot be
  305.   evel events              | | |     accessed by applications running on
  306.                            | | |     other computers on a network.
  307.                            | | | 1 = Your application is accessible by
  308.                            | | |     applications running on other
  309.                            | | |     computers on a network, and it can
  310.                            | | |     receive high-level events across a
  311.                            | | |     network (System 7 only, or higher).
  312. ---------------------------+-+-+----------------------------------------
  313. Stationery aware           | |0| 0 = If the user opens a stationary
  314.                            | | |     document (System 7 only, or
  315.                            | | |     higher), the Finder makes a copy of
  316.                            | | |     the file and asks the user to name
  317.                            | | |     the copy.
  318.                            | | | 1 = Your application knows how to work
  319.                            | | |     with stationery documents (System 7
  320.                            | | |     only, or higher).
  321. ---------------------------+-+-+----------------------------------------
  322. Use text edit services     | |0| 0 = Your application does not use
  323.                            | | |     inline TextEdit services
  324.                            | | | 1 = Your application uses inline
  325.                            | | |     TextEdit services (System 7 only,
  326.                            | | |     or higher).
  327.                            | | | Tools Plus’s editing fields don’t use
  328.                            | | | inline TextEdit services.  Set this
  329.                            | | | item to 1 only if you have designed
  330.                            | | | your own editing fields that use these
  331.                            | | | services.
  332. ---------------------------+-+-+----------------------------------------
  333. Reserved bit               |0|0| (reserved for future use)
  334. ---------------------------+-+-+----------------------------------------
  335. Reserved bit               |0|0| (reserved for future use)
  336. ---------------------------+-+-+----------------------------------------
  337. Reserved bit               |0|0| (reserved for future use)
  338. ---------------------------+-+-+----------------------------------------
  339. Size                       | | | The memory size at which your
  340.                            | | | application can run most efficiently.
  341.                            | | | When your application is launched, the
  342.                            | | | Operating System tries to secure this
  343.                            | | | amount of memory.
  344. ---------------------------+-+-+----------------------------------------
  345. Min size                   | | | The memory limit below which your
  346.                            | | | application will not run.
  347. ---------------------------+-+-+----------------------------------------
  348.  
  349.  
  350.  
  351.  
  352.  
  353. Cloned SIZE resources
  354. `````````````````````
  355. Although you need to create only one SIZE resource (ID=-1), the Macintosh may make clones of it when the user makes changes in the Finder’s “Get Info” box.  When the user makes changes in the “Get Info” box, the Macintosh clones (makes a copy of the SIZE resource with ID=-1) and lets the user makes changes to the “Size” and “Min size” fields of the clone.  You only need to be concerned with this if you want to preset your application’s memory requirements to something other that the recommended limits defined by your original SIZE resource.
  356.  
  357. The table below describes the contents of the “Size” and “Min size” fields for the original SIZE resource, as well as any clones that may be created by the Macintosh.
  358.  
  359.  
  360. System File|SIZE| Field’s | Title in       |
  361.   Version  | ID |  Name   | “Get Info” box | Contents
  362. -----------+----+---------+----------------+----------------------------
  363. 5 to 7.0.x | -1 |Size     |Application     | Memory required for optimum
  364.            |    |         |memory size     | performance
  365.            |    +---------+----------------+----------------------------
  366.            |    |Min size |Suggested memory| Memory limit below which
  367.            |    |         |size            | your application won’t run
  368.            +----+---------+----------------+----------------------------
  369.            | 0  |Size     |Application     | User’s setting
  370.            |    |         |memory size     |
  371.            |    +---------+----------------+----------------------------
  372.            |    |Min size |Suggested memory| Memory limit below which
  373.            |    |         |size            | your application won’t run
  374.            |    |         |                | (same as ID=-1)
  375. -----------+----+---------+----------------+----------------------------
  376. 7.1 or     | -1 |Size     |Suggested size  | Memory required for optimum
  377. higher     |    |         |                | performance
  378.            |    +---------+----------------+----------------------------
  379.            |    |Min size |(not displayed) | Memory limit below which
  380.            |    |         |                | your application won’t run
  381.            +----+---------+----------------+----------------------------
  382.            | 0  |Size     |Preferred size  | User’s preferred memory
  383.            |    |         |                | allowance
  384.            |    +---------+----------------+----------------------------
  385.            |    |Min size |(not displayed) | Memory limit below which
  386.            |    |         |                | your application won’t run
  387.            |    |         |                | (same as ID=-1)
  388.            +----+---------+----------------+----------------------------
  389.            | 1  |Size     |(not displayed) | User’s preferred memory
  390.            |    |         |                | allowance
  391.            |    |         |                | (same as ID=0)
  392.            |    +---------+----------------+----------------------------
  393.            |    |Min size |Minimum size    | User’s minimum memory
  394.            |    |         |                | allowance below which the
  395.            |    |         |                | application won’t run.
  396. -----------+----+---------+----------------+----------------------------
  397.